// pc/02user/invitedMe.js
var co = require('../../js/common.js')
var ws = require('../../js/websocket.js')
var app = getApp()
var that
Page({
   data: {
      inviterInfo: '',
      iInvitedList: []
   },

   onLoad: function (options) {
      that = this
      var param = { unionid: app.aData.userInfo.inviter_uid }
      co.getShareApi('user/Mg/invitedMe', param, function (res) {
         that.setData({ inviterInfo: res.data })
      })

      var param = { inviter_uid: app.aData.userInfo.unionid }
      co.getShareApi('user/Mg/iInvitedlist', param, function (res) {
         that.setData({ iInvitedList: res.data })
      })

      ws.setNoticeAddMyInvitedUser(function (res) {
         if (res.inviter_uid = param.inviter_uid){
            var obj = [{
               avatarUrl: res.avatarUrl,
               nickName: res.client_name,
               time: res.time
            }]
            var list = that.data.iInvitedList
            that.setData({ iInvitedList: obj.concat(list) })
         }
      })
   },

   //去邀请的好处
   toInvitationBenefits: function () {
      wx.navigateTo({
         url: '/platform/03/invitationBenefits',
      })
   },

   onShareAppMessage: function () {
      var urlParam = ''
      if (app.aData.userInfo.user_id) {
         urlParam = '?inviter_oid=' + app.aData.userInfo.openid + '&inviter_uid=' + app.aData.userInfo.unionid
      }
      var share = {
         title: '【门业维修共享平台】',
         path: '/home/01homePage/home' + urlParam,
         imageUrl: 'http://img.ls293.cc/repair/share_img.png'
      }
      console.log('【分享】share', share)
      return share
   }


})
